package com.javabase.y2022.m04.day0423.e01;

/**
 * @descriptions:
 * @author: Tom
 * @date: 2022/4/23 下午 04:10
 * @version: 1.0
 */
public class Solution {
    public static void main(String[] args) {
        int[] arr = new int[]{1,3,5,7,9,11,13,15};
        find(arr, 6);
    }
    public static boolean find(int[] arr, int target){
        int L = 0;
        int R = arr.length - 1;
        // 循环里面至少有2个数
        while(L <= R){
            int mid = L + ((R -L)  >> 1);
            if(arr[mid] == target){
                return true;
            } else if(arr[mid] > target){
                R = mid - 1;
            } else {
               L = mid + 1;
            }
        }
        return arr[L] == target;
    }
}
